package core;

import org.newdawn.slick.Image;

import java.awt.Dimension;
import java.awt.Rectangle;

abstract class Entity {
	private Image sprite;  		//graphic
	private float x, y; 		//coordinates
	public float getX() {
		return x;
	}

	public void setX(float x) {
		this.x = x;
	}

	public float getY() {
		return y;
	}

	public void setY(float y) {
		this.y = y;
	}

	public Dimension getBounds() {
		return bounds;
	}

	public void setBounds(Dimension bounds) {
		this.bounds = bounds;
	}

	private String name;		//identifier
	private Dimension bounds;	//collision box
	
	public Entity() {
		setName(new String("Default -- Give me a name"));
		x = 0; 
		y = 0;
		bounds = new Dimension(0,0);
	}
	
	public boolean doCollide(Entity b) {
		
		float left1, left2;
		float right1, right2;
		float top1, top2;
		float bottom1, bottom2;
		
		left1 = this.x;
		left2 = b.x;
		right1 = this.x + this.getBounds().width;
		right2 = b.x + b.getBounds().width;
		top1 = this.y;
		top2 = b.y;
		bottom1 = this.y + this.getBounds().height;
		bottom2 = b.y + b.getBounds().height;
		
		if (bottom1 < top2) return false;
		if (top1 > bottom2) return false;

		if (right1 < left2) return false;
		if (left1 > right2) return false;

		return true;
		
	}
	
	//public abstract void update();
	

	public Image getSprite() {
		return sprite;
	}

	public void setSprite(Image sprite) {
		this.sprite = sprite;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	
}
